package com.hooya.fa.eu.biz.controller;

import com.hooya.fa.eu.biz.service.EuHistoryService;
import com.hooya.integrated.common.core.util.R;
import com.hooya.integrated.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 欧洲审计历史数据
 * @Author : Zongz
 * @Copyright Copyright (c) 豪雅集团
 * @Create 2024/3/19
 * @Version 1.0.0
 */
@RestController
@RequiredArgsConstructor
@Tag(name = "欧洲历史数据")
@RequestMapping("/eu/his")
public class EuHistoryController {

    private final EuHistoryService euHistoryService;


    @PostMapping("/generator")
    @Inner(value = false)
    @Operation(summary = "生成eu历史数据【√】", hidden = true,
            description = "根据excl文件，将报表存入数据库【时间格式：2024-01-01】")
    public R genEuHistoryData(@RequestParam("start") String start, @RequestParam("end") String end) {
        euHistoryService.genEuHistoryData(start, end);
        return R.ok();
    }


    @PostMapping("/append/mmjl")
    @Inner(value = false)
    @Operation(summary = "历史数据新增restock买卖数据", hidden = true,
            description = "根据指定文件夹中的excel，获取sheet为restock_mmjl的数据，加入至append_temp_mmjl")
    public R appendMmjl() {
        euHistoryService.appendMmjl();
        return R.ok();
    }


    @PostMapping("/order/belongs")
    @Inner(value = false)
    @Operation(summary = "订单归属获取【√】", hidden = true, description = "根据发票号找出发票中所有sku的销售记录")
    public R getOrderBelongs() {
        euHistoryService.getOrderBelongs();
        return R.ok();
    }


    @PostMapping("/order/edit")
    @Inner(value = false)
    @Operation(summary = "销售记录修改【√】", hidden = true, description = "在销售记录上添加税率，配合getOrderBelongs()方法用")
    public R editOrderExcel() {
        euHistoryService.editOrderExcel();
        return R.ok();
    }

    @PostMapping("/sell/report")
    @Inner(value = false)
    @Operation(summary = "销售报表", hidden = true,
            description = "生成销售报表：{主体内容，销售数据，对应的发票、发票货权，发票数量。其他：外销单价...}")
    public R genSellReport(@RequestParam("start") String start, @RequestParam("end") String end,
                           @RequestParam("his") boolean his, @RequestParam("sale") boolean sale) {
        euHistoryService.genSellReport(start, end, his, sale);
        return R.ok();
    }

}
